package com.ruoyi.project.zxcrm.mapper;


import com.ruoyi.common.zx.PageData;
import com.ruoyi.project.zxcrm.domain.CrmOrder;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Select;

import java.util.List;

/**
 * 客户订单Mapper接口
 *
 * @author mn
 * @date 2022-12-30
 */
@Mapper
public interface CrmOrderMapper
{
    /**
     * 查询客户订单
     *
     * @param id 客户订单主键
     * @return 客户订单
     */
    public CrmOrder selectCrmOrderById(Long id);

    /**
     * 查询客户订单列表
     *
     * @param crmOrder 客户订单
     * @return 客户订单集合
     */
    public List<CrmOrder> selectCrmOrderList(CrmOrder crmOrder);

    /**
     * 新增客户订单
     *
     * @param crmOrder 客户订单
     * @return 结果
     */
    public int insertCrmOrder(CrmOrder crmOrder);

    /**
     * 修改客户订单
     *
     * @param crmOrder 客户订单
     * @return 结果
     */
    public int updateCrmOrder(CrmOrder crmOrder);

    /**
     * 删除客户订单
     *
     * @param id 客户订单主键
     * @return 结果
     */
    public int deleteCrmOrderById(Long id);

    /**
     * 批量删除客户订单
     *
     * @param ids 需要删除的数据主键集合
     * @return 结果
     */
    public int deleteCrmOrderByIds(Long[] ids);

    @Select("SELECT\n" +
            "\tt1.id,\n" +
            "\tt1.customer_id,\n" +
            "\tt2.`name` customer_name,\n" +
            "\tt2.mobile,\n" +
            "\tt1.state \n" +
            "FROM\n" +
            "\tcrm_order t1\n" +
            "\tLEFT JOIN bd_partner t2 ON t1.customer_id = t2.id \n" +
            "WHERE\n" +
            "\tt1.state = 1 \n" +
            "ORDER BY\n" +
            "\tt1.update_time DESC")
    public List<PageData> queryCrmLeadList();
}
